import React from 'react';
import { Provider } from 'mobx-react';
import { WeaLocaleProvider } from 'ecCom';

//表单修改日志
import WfFormModifyLogCom from './components/form-modify-log/LogContent';
import WfFormModifyLogStore from './stores/formModifyLogStore';
//表单相关资源
import WfFormResourceCom from './components/form-resource/Resource';
import WfFormResourceStore from './stores/formResourceStore';
//签字意见列表
import WfFormLogListCom from './components/form-logList/index';
import WfFormLogListStore from './stores/formLogListStore';
//转发
import WfForward from './components/wf-forward/index';
import WFForwardStore from './stores/forwardStore';
//签字意见输入框
import WfSignInput from './components/wf-sign-input/index';
//流程中心
import WfCenterLogList from './components/wf-center-loglist/index';
import WfCenterLogListStore from './stores/wfCenterLogListStore';
//批量提交
import WfBatchSubmit from './components/wf-batch-submit/index';

//添加共享
import WfFormShare from './components/wf-add-share/List';
import WfBatchShare from './components/wf-add-share/ShareBatch';
import WfFormShareStore from './stores/share/wfShareForm';
import WfBatchShareStore from './stores/share/wfShareBatch';

//转发收回
import ForwardBack from './components/wf-forwardback/index';
import WfForwardBackStore  from './stores/forwardBackStore';

//相关交流
import FormCommunicationCom from './components/form-communication/index';
import WfFormCommunicationStore from './stores/communicationStore';

//流程二次验证
import SecondAuth from "./components/second-auth/index";
import SecondAuthStore from "./stores/secondAuthStore";
import SecondAuthDetail from "./components/second-auth-detail/index";

//移动端模块配置界面
import MobileSettingCom from './components/mobile-setting/index';
import MobileSettingStore from './stores/mobileSettingStore';

import RemindSet from './components/wf-remind/index';
import RemindTypelist from './components/wf-remind-typelist/index';
import RemindSetStore from './stores/remindSet';

//添加批示语

import UserPhraseEdit from './components/wf-user-phrase-edit/index';
import UserPhraseEditStore from './stores/UserPhraseEdit';

//流程关注
import TagTypeSelect from "./components/wf-followType-select/index";
import FollowTypeSettingStore from "./stores/followTypeSetting";
import TagTypeSelectDialog from "./components/wf-followType-select/TagTypeSelectDialog";


//自由流程流程图
import FreeFlowDesignContainer from './components/wf-free-chart/index';
import FreeFlowDesignSvg from './components/wf-free-chart/WorkflowFreeDrawSvg';
import { WorkflowNewDesignStore } from './stores/freeTemplateSup';


//公文转办
import GWWfForward from './components/wf-gwforward/index';
import WFForwardGWStore from './stores/forwardGWStore';


//相关流程
import RelatedWorkflow from './components/form-relatedWorkflow/index'
import RelatedWorkflowStore from './stores/relatedWorkflowStore'

require('./util/img_zoom');

const swapLocaleProvider = (Component,refMark = '') =>{
    return class Main extends React.Component{
        constructor(props) {
            super(props);
            this.state = {
                reRender: false,
            };
        }
        componentDidMount() {
            WeaLocaleProvider.getLocaleLabelByCode('workflow').then(() => this.setState({ reRender: true }));
        }
        render(){
            const { reRender } = this.state;
            return <Component ecId={`${this && this.props && this.props.ecId || ''}_Component@apu1vc`} ref={refMark} {...this.props} {...this.state} />
        }
    }
}

const swapStoreProvider = (Component, Store, storename) =>{
    return class Main extends React.Component{
        constructor(props) {
            super(props);
            this.state = {
                reRender: false,
                providerProps: {[storename]: new Store()}
            };
        }
        componentDidMount() {
            WeaLocaleProvider.getLocaleLabelByCode('workflow').then(() => this.setState({ reRender: true }));
        }
        render(){
            const { reRender,providerProps } = this.state;
            return (
                <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@bo8pcc`} {...providerProps}>
                    <Component ecId={`${this && this.props && this.props.ecId || ''}_Component@6wgdx3`} {...this.props} />
                </Provider>
            )
        }
    }
}

module.exports = {
    WfFormModifyLogCom: swapLocaleProvider(WfFormModifyLogCom),
    WfFormModifyLogStore,
    WfFormResourceCom: swapLocaleProvider(WfFormResourceCom),
    WfFormResourceStore,
    WfFormLogListCom: swapLocaleProvider(WfFormLogListCom),
    WfFormLogListStore,
    WfForward: swapLocaleProvider(WfForward),
    WFForwardStore,
    GWWfForward: swapLocaleProvider(GWWfForward),
    WFForwardGWStore,
    WfSignInput: swapLocaleProvider(WfSignInput,'signInput'),
    WfCenterLogList: swapLocaleProvider(WfCenterLogList),
    WfCenterLogListStore,
    WfBatchSubmit: swapLocaleProvider(WfBatchSubmit),
    WfFormShare: swapLocaleProvider(WfFormShare),
    WfFormShareStore,
    WfBatchShare: swapLocaleProvider(WfBatchShare),
    WfBatchShareStore,
    WfForwardBack : swapLocaleProvider(ForwardBack),
    WfForwardBackStore,
    WfFormCommunicationCom : swapLocaleProvider(FormCommunicationCom),
    WfFormCommunicationStore,
    SecondAuthCom: swapLocaleProvider(SecondAuth),
    SecondAuthStore: new SecondAuthStore(),
    SecondAuthDetailCom: swapLocaleProvider(SecondAuthDetail),
	  WfMobileSettingCom: swapStoreProvider(MobileSettingCom, MobileSettingStore, "wfMobileSettingStore"),
    RemindSet : swapLocaleProvider(RemindSet),
    RemindSetStore,
    RemindTypelist : swapLocaleProvider(RemindTypelist),
    UserPhraseEditStore,
    UserPhraseEdit: swapLocaleProvider(UserPhraseEdit),
    TagTypeSelect: swapLocaleProvider(TagTypeSelect),
    TagTypeSelectDialog: swapLocaleProvider(TagTypeSelectDialog),
    FollowTypeSettingStore,
    WorkflowNewDesignStore,
    FreeFlowDesignContainer: swapLocaleProvider(FreeFlowDesignContainer),
    FreeFlowDesignSvg: swapLocaleProvider(FreeFlowDesignSvg),
    RelatedWorkflow:swapLocaleProvider(RelatedWorkflow),
    RelatedWorkflowStore,
   
}
  